import {Component, Input, OnDestroy, OnInit, SimpleChanges} from '@angular/core';
import {TagData} from '../../../../entity/tag-data.model';
import {TurbstatusData, TurbstatusTable} from '../turbstatus-panel/turbstatus-panel.component';

import {fadeIn} from '../../../../../platform/zknwui/core/common/animation/fadeIn-animation';

@Component({
  selector: 'app-turboper-panel',
  templateUrl: './turboper-panel.component.html',
  styleUrls: ['./turboper-panel.component.css'],
  animations: [fadeIn]

})
export class TurboperPanelComponent implements OnInit, OnDestroy {
  /**
   * 检修标题
   *
   * @type {string}
   * @memberof TurboperPanelComponent
   */
  @Input()
  public title: string = '风机检修';

  /**
   * 风机操作统计
   *
   * @type {TurbstatusData[]}@memberof TurbstatusPanelComponent
   */
  @Input()
  public totalTurboperDatas: TurboperData[];

  /**
   * 风机操作统计明细
   *
   * @type {TurbstatusData[]}@memberof TurbstatusPanelComponent
   */
  @Input()
  public turboperTable: TurbstatusTable;


  public powerShow: boolean = false;
  @Input()
  public maxValue: number;

  constructor() {
  }

  ngOnChanges(changes: SimpleChanges) {
    if (changes['totalTurboperDatas'] && changes['totalTurboperDatas'].currentValue) {

    }
  }

  ngOnInit() {
    // this.turboperCategoryService.getTurboperCategoryWithTotalTurbine()
    //   .then(res=>{
    //     this.turboperCategorys = [...res];
    //    }).catch(error => {
    //     throw new Error(error);
    //   });
    // this.turboperCategoryService.getTurboperCategoryWithTotalTurbine()
    //   .then(res=>{
    //     this.turboperCategorys = [...res];
    //    }).catch(error => {
    //     throw new Error(error);
    //   });
  }

  ngOnDestroy(): void {
  }

  enterPower() {
    this.powerShow = true;
  }

  leavePower() {
    this.powerShow = false;
  }
}

export interface TurboperData {
  id: number;
  name: string;
  color: string;
  value: number;
}

export interface TurboperTable {
  rows: TurboperRow[];
  title: string[];
}

export interface TurboperRow {
  columns: TurboperColumn[];
  farmName: string;
  farmId: number;
}

export interface TurboperColumn {
  value: any,
  color?: string,
  operId?: number,
  farmId?: number,
  turbineState?: TagData[]
}
